/**
 * 
 */
package com.google.ddcharacter.data;

import java.util.Date;
import javax.jdo.annotations.*;
import com.google.appengine.api.users.User;

/**
 * @author James
 *
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Account {
	
	/**
	 * Primary key for account table.
	 */
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private long id;
	
	/**
	 * User object for easy reference.
	 */
	@Persistent
	private User user;
	
	/**
	 * Time and date of last login.
	 */
	@Persistent
	private Date lastLogin;
	
	/**
	 * Time are date when user created their account.
	 */
	@Persistent
	private Date createDate;
	
	
	public Account(User user) {
		this.user = user;
		this.createDate = new Date();
	}
	
	/**
	 * getId()
	 * 
	 * @return id
	 */
	public long getId() {
		return id;
	}
	
	/**
	 * getUser()
	 * 
	 * @return user
	 */
	public User getUser() {
		return user;
	}
	
	/**
	 * getLastLogin()
	 * 
	 * @return lastLogin
	 */
	public Date getLastLogin() {
		return lastLogin;
	}
	
	/**
	 * getCreateDate()
	 * 
	 * @return createDate
	 */
	public Date getCreateDate() {
		return createDate;
	}
	
	/**
	 * setLastLogin()
	 * 
	 * @return lastLogin
	 */
	public Date setLastLogin() {
		lastLogin = new Date();
		
		return lastLogin;
	}
}
